﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Threading;
using Hi_Baidu.ProcessModel;

namespace Hi_Baidu.Timer
{
    class PostAddFriendResult_TimeOutEvent : TimeOutEvent
    {
        private Hi_Baidu.ProcessModel.FriendProcessModel.ADDFRIEND_RESULT Result;
        private byte[] username;
        private  Notify.Notify NotifyObject;
        private byte[] ItemId;
        /// <summary>
        ///     提供了发送添加好友结果的超时计算与相关操作
        /// </summary>
        /// <param name="Result">添加好友结果</param>
        /// <param name="username">用户名</param>
        /// <param name="NotifyObject">提示对象</param>
        /// <param name="Key">唯一标示</param>
        /// <param name="Interval">触发间隔</param>
        /// <param name="TryCount">总共尝试次数</param>
        public PostAddFriendResult_TimeOutEvent(Hi_Baidu.ProcessModel.FriendProcessModel.ADDFRIEND_RESULT Result, byte[] username, Notify.Notify NotifyObject, byte[] ItemId, String Key, int Interval, int TryCount)
            : base(Key, Interval, TryCount)
        {
            this.Result = Result;
            this.ItemId = ItemId;
            this.username = username;
            this.NotifyObject = NotifyObject;
            this.OnTryFull += new EventHandler<EventArgs>(PostAddFriendResult_TimeOutEvent_OnTryFull);
            this.OnTick += new EventHandler<EventArgs>(PostAddFriendResult_TimeOutEvent_OnTick);
        }

        void PostAddFriendResult_TimeOutEvent_OnTick(object sender, EventArgs e)
        {
            //重试操作
            FriendProcessModel.PostAddFriendResult(this.Result, this.NotifyObject, this.username, ItemId);
        }

        void PostAddFriendResult_TimeOutEvent_OnTryFull(object sender, EventArgs e)
        {
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new PUBLIC_DELEGATE(Globle.ShowWindow));
        }


    }
}
